home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d3 / rettig.arc / TRSOURCE.EXE / TR_NTXSZ.PRG < prev    next >
Text File  |  1990-10-22  |  833b  |  30 lines

  1. *********
  2. *  TR_NTXSZ.PRG
  3. *
  4. *  by Tom Rettig and Leonard Zerman
  5. *
  6. * Placed in the public domain by Tom Rettig Associates, 10/22/1990.
  7. *
  8. *  Syntax: NTXSIZE( <key length>, <expN> )
  9. *  Return: <expN> integer maximum potential number of bytes in index file
  10. *********
  11.  
  12. FUNCTION NTXSIZE
  13. *
  14. PARAMETERS keylen, last_recno
  15.  
  16. IF last_recno == 0
  17.    RETURN 2048      && size of empty ntx file, any key size
  18. ELSE
  19.    RETURN ( INT(last_recno/INT(((1020/(keylen+10))-1)/2))+1 ) * 1024
  20. ENDIF
  21.  
  22. * return statement is based on this algorithm:
  23. * maxitem = 1020 / (keylen+10)              && max items per node
  24. * minkeys = int( (maxitem-1) / 2 )          && min keys per node
  25. * knodes  = int( last_recno / minkeys )     && kbytes of nodes
  26. * return (knodes+1) * 1024                  && add one for the header
  27.  
  28. * eofunc ntxsize
  29.  
  30.